/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.util.Hashtable;
import jpl.Atom;
import jpl.Query;
import jpl.Term;

/**
 *
 * @author Raul
 */
public class GestorProlog {
    private Query consulta;
    private Hashtable[] soluciones;

    public GestorProlog() {
    }

    public Query getConsulta() {
        return consulta;
    }

    public void setConsulta(Query consulta) {
        this.consulta = consulta;
    }
    
    public void consultarArchivo(String dir){
        setConsulta(new Query("consult",new Term[] {new Atom(dir)}));
        System.out.println( "consult " + 
                dir.replaceAll(".*/", "") +
                (getConsulta().hasSolution() ? " succeeded" : " failed"));
    }
    
    public void consultar(String consulta){
        setConsulta(new Query(consulta));
        soluciones =  getConsulta().allSolutions();
    }

    public Hashtable[] getSoluciones() {
        return soluciones;
    }

}
